package com.ruoyi.quality.controller;


import com.ruoyi.common.core.domain.R;
import com.ruoyi.quality.domain.dto.SamplingItemDto;
import com.ruoyi.quality.service.SamplingItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

@RestController
@RequestMapping("/samplingItem")
public class SamplingItemController {
    @Autowired
    SamplingItemService samplingItemService;

    @PostMapping("/getSamplingItemByPage")
    public R export(@RequestBody SamplingItemDto materialDto)
    {
        return R.ok(samplingItemService.getSamplingItemByPage(materialDto));
    }

    @PostMapping("/addSamplingItem")
    public R addTest(@RequestBody SamplingItemDto materialDto) throws ParseException {
        samplingItemService.addSamplingItem(materialDto);
        return R.ok("添加成功");
    }

    @PostMapping("/delSamplingItem")
    public R delTest(@RequestBody SamplingItemDto materialDto){
        samplingItemService.delSamplingItem(materialDto);
        return R.ok("删除成功");
    }

    @PostMapping("/updateSamplingItem")
    public R updateTest(@RequestBody SamplingItemDto materialDto){
        samplingItemService.updateSamplingItem(materialDto);
        return R.ok("锁定成功");
    }
}
